let logger = require("pomelo-logger").getLogger(__filename);
let path = require("path");

module.exports = function (app) {
    return function () {
        initialize(app);
    };
};

function initialize(app) {
    app.set('proxyConfig', {
        retryTimes: -1
    });

    logger.info("initialize zhuoji server");
    app.loadConfig("rooms", path.join(app.getBase(), "/config/zhuoji/rooms.json"));

    let zhuojiTableService = require(path.join(app.getBase(), "/app/domain/games/mahjong/zhuojiTableService")).create(app);
    app.set('zhuojiTableService', zhuojiTableService);

    let ZhuojiRobotService = require(path.join(app.getBase(), "/app/domain/games/mahjong/zhuojiRobotService"));
    let zhuojiRobotService = new ZhuojiRobotService();
    app.set('zhuojiRobotService', zhuojiRobotService);
    zhuojiRobotService.initialize();
}